<?php
class Customers extends Public_Controller
{
	
	public function __construct()
	{
		parent::__construct();
	}
	
	public function index()
	{
		$data['customer'] = new Customer;
		$data['customer']->where_related_user('id',$this->session->userdata('id'))->get();
		$this->template->build('index',$data);
	}
	
	public function save($id = NULL)
	{
		if($_POST)
		{
			$customer = new Customer;
			$customer->where_related_user('id',$this->session->userdata('id'))->get();
			$customer->user_id = $this->session->userdata('id');
			$customer->from_array($_POST);
			$customer->save();
			set_notify('success','บันทึกข้อมูลเรียบร้อยแล้วค่ะ');
		}
		redirect('customers');
	}
	
	
}
?>